package com.xx.servlet.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class LoginServlet extends HttpServlet {

	
	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String uname=request.getParameter("uname");
		
		ServletContext application=getServletContext();
		List<String> nameList=(	List<String> )application.getAttribute("nameList");
		if(nameList==null){
			nameList = new ArrayList<String>();
			
		}
      nameList.add(uname);
      application.setAttribute("nameList", nameList);
      HttpSession session=request.getSession();
      session.setAttribute("uname", uname);
      
      response.sendRedirect("main.jsp");
      
      
	}

}
